<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/bootstrap/dist/css/bootstrap.min.css}">
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/font-awesome/css/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/Ionicons/css/ionicons.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/adminlte/dist/css/AdminLTE.min.css}">
    <!-- AdminLTE Skins. We have chosen the skin-blue for this starter
          page. However, you can choose any other skin. Make sure you
          apply the skin class to the body tag so the changes take effect. -->
    <link rel="stylesheet" th:href="@{/adminlte/dist/css/skins/_all-skins.min.css}">

    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>

    <title>标椎地名地址管理系统</title>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    <div th:replace="common/user_header :: user_header"></div>

    <div th:replace="common/user_menu :: user_menu"></div>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper" >
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                Page Header
                <small>Optional description</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i>门牌申请</a></li>
                <li class="active">申请新门牌</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content container-fluid">

            <div class="row">
                <!-- left column -->
                <div class="col-md-1">


                </div>
                <!--/.col (left) -->
                <!-- right column -->
                <div class="col-md-10">
                    <!-- Horizontal Form -->
                    <div class="box box-info">
                        <div class="box-header with-border">
                            <h3 class="box-title">Horizontal Form</h3>
                        </div>
                        <!-- /.box-header -->
                        <!-- form start -->
                        <form class="form-horizontal" th:action="@{/User/apply}" method="post" >
                            <div class="box-body">
                                <input type="hidden" name="userId" th:value="${session.current_user.userId}">
                                <input type="hidden" name="state" value="审核中">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">areaName:</label>
                                    <div class="col-sm-10">
                                        <select class="form-control" name="areaId" id="categoryLevel1">

                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">streetName:</label>
                                    <div class="col-sm-10">
                                        <select class="form-control" name="streetId" id="categoryLevel2">

                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">doorNumber:</label>
                                    <div class="col-sm-10">
                                        <select class="form-control" name="doorId" id="categoryLevel3">

                                        </select>
                                    </div>
                                </div>


                            </div>
                            <!-- /.box-body -->
                            <div class="box-footer">
                                <button type="submit" class="btn btn-default">Cancel</button>
                                <button type="submit" class="btn btn-info pull-right">Submit</button>
                            </div>
                            <!-- /.box-footer -->
                        </form>
                    </div>
                </div>
                <!--/.col (right) -->
                <div class="col-md-1">


                </div>
            </div>

            <!--------------------------
              | Your Page Content Here |
              -------------------------->

            <!--<form th:action="@{/Area/add}" method="post" th:object="${area}">-->
            <!--<table>-->
            <!--<tr>-->
            <!--<td>areaName:</td>-->
            <!--<td>-->
            <!--<input type="hidden" name="areaId" th:field="*{areaId}">-->
            <!--<input type="text" name="areaName" th:field="*{areaName}">-->
            <!--</td>-->
            <!--</tr>-->
            <!--<tr>-->
            <!--<td>areaMap:</td>-->
            <!--<td><input type="text" name="areaMap" th:field="*{areaMap}"></td>-->
            <!--</tr>-->
            <!--<tr>-->
            <!--<td></td>-->
            <!--<td><input type="submit"></td>-->
            <!--</tr>-->
            <!--</table>-->
            <!--</form>-->

        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <div th:replace="common/footer :: footer"></div>



</div>
<!-- ./wrapper -->

<!-- REQUIRED JS SCRIPTS -->

<!-- jQuery 3 -->
<script th:src="@{/adminlte/bower_components/jquery/dist/jquery.min.js}"></script>
<!-- Bootstrap 3.3.7 -->
<script th:src="@{/adminlte/bower_components/bootstrap/dist/js/bootstrap.min.js}"></script>
<!-- AdminLTE App -->
<script th:src="@{/adminlte/dist/js/adminlte.min.js}"></script>

<script>





    $(document).ready(function(){
        var categoryLevel1 = $("#categoryLevel1"); //拿到一级下拉框元素
        categoryLevel1.append("<option>请选择</option>")
        $.ajax({
            type: "GET",//请求类型
            url: "/User/findArea",//请求的url
            dataType: "json",//ajax接口（请求url）返回的数据类型
            success: function (data) {
                if (data != null) {
                    for (var i = 0; i < data.length; i++) { //将值填充到下拉框
                        categoryLevel1.append('<option value="' + data[i].areaId + '">' + data[i].areaName + '</option>')
                    }
                }
            },
            error: function (data) {
                console.log(data);
            }
        });

        //二级下拉框
        $("#categoryLevel1").change(function () { //当一级下拉框改变时
            $("#categoryLevel2").find("option").remove(); //把二级下拉框原来的值先清除
            var areaId = $("#categoryLevel1").val();//拿到一级下拉框值
            var categoryLevel2 = $("#categoryLevel2");//拿到二级下拉框元素
            categoryLevel2.append("<option>请选择</option>")
            if (areaId != null) {
                $.ajax({
                    type: "GET",//请求类型
                    url: "/User/findStreet",//请求的url
                    data: {id: areaId},//请求参数
                    dataType: "json",//ajax接口（请求url）返回的数据类型
                    success: function (data) {//data：返回数据（json对象）
                        if (data != null) {
                            for (var i = 0; i < data.length; i++) {//将值填充到下拉框
                                $(categoryLevel2).append('<option value="' + data[i].streetId + '">' + data[i].streetName + '</option>')
                            }
                        }
                    },
                    error: function (data) {
                        console.log(data);
                    }
                })
            }
        });

        //三级下拉框
        $("#categoryLevel2").change(function () { //当二级下拉框改变时
            $("#categoryLevel3").find("option").remove(); //把三级下拉框原来的值先清除
            var streetId = $("#categoryLevel2").val();//拿到二级下拉框值
            var categoryLevel3 = $("#categoryLevel3");//拿到三级下拉框元素
            if (streetId != null) {
                $.ajax({
                    type: "GET",//请求类型
                    url: "/User/findDoor",//请求的url
                    data: {id: streetId},//请求参数
                    dataType: "json",//ajax接口（请求url）返回的数据类型
                    success: function (data) {//data：返回数据（json对象）
                        if (data != null) {
                            for (var i = 0; i < data.length; i++) {//将值填充到下拉框
                                $(categoryLevel3).append('<option value="' + data[i].doorId + '">' + data[i].doorNumber + '</option>')
                            }
                        }
                    },
                    error: function (data) {
                        console.log(data);
                    }
                })
            }
        });
    });


    
</script>

<!-- Optionally, you can add Slimscroll and FastClick plugins.
     Both of these plugins are recommended to enhance the
     user experience. -->
</body>
</html>